const path = require("path");
const time = require("dayjs")
require('dotenv').config({path: path.join(__dirname, '../.env')})


let skipStaticRegex = /(\.(?:js|css|png|jpg|jpeg|gif|svg|ico|woff|woff2)$)/i
module.exports = {
    //数据库类配置文件
    database: {
        //     文件的存放路径
        dbFilePath: path.join(__dirname, '../database'),
        dbFileName: process.env["AA_TB_APPKEY"] + '.db'
    },
    //缓存类配置
    cache: {
        // 缓存控制器的总阀门 若为真 则开启缓存 生产环境建议开启
        isCached: false,
        // 缓存控制器 配置缓存文件的路径 相对于此目录
        cacheDir: path.join(__dirname, '../', './cache')
    },
    // 日志类配置文件
    log: {
        // 指定日志的存放路径
        runTimeLogFilePath: path.join(__dirname, '../log'),
        //日志的文件格式 示例是代表
        runTimeLogFileName: `runTime-${time().format('YYYY-MM-DD')}.log`
    },
    rateLimit: {
        windowMs: 5 * 60 * 1000, // unit microsecond
        max: 10, // limit each IP to 100 requests per windowMs
        skipFailedRequests: true,
        skipSuccessfulRequests: false,
        message: (req, res) => {
            let pageData = {}
            res.render('news/oftenVisits.html', pageData)
            // return html || "<h1>Too many requests, please try again later</h1>"
        },
        skip: req => {
            if(req.path === '/' || skipStaticRegex.test(req.path)){
                return true
            }
        }
    },
    // 备份
    backUp: {
        time: null,
        // 这里写一个定期备份配置文件的函数
        do: () => {
        }
    },
    // 悬浮球
    "livechat-girl": {
        display: 'none'
    },
    "about_text": `            <p>
                                    在浏览设计，运营，优化，建站等资料文章时，感觉到很多新手都碰到各种各样的问题，同时网上真正分享经验比较少。我何不一边学习，一边分享我积累的经验呢。
                                    所以建立了这个网站。 See you in BLOG…</p>
                                    <p>如果您有任何问题，欢迎与我们联系!</p>
                                    <p>在线客服：QQ872872015</p>
                                    <p>电子邮箱：riemo@foxmail.com</p>
                                    <p>When browsing design, operation, optimization, website building and other
                                        materials and articles, I feel that many novices are confronted with various
                                        problems, at the same time, there is less real experience sharing online. Why
                                        don't I share my experience while learning. So we set up this website. See you
                                        in BLOG…</p>
                                    <p>感谢您对我们的支持与关注。</p>
                                    <p><img src="okle/picture/742615498.png" alt="webcad.png" title="webcad.png"></p>
                                    ...`
}